package com.actions.bluetoothbox2.util;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

import com.actions.bluetoothbox2.R;

import java.util.List;

/**
 * Created by 刘勇和敬晓凤 on 2018/6/12.
 */

public class PopupVoiceSelecter2Adapter extends BaseAdapter {

    Context context;
    List<VoiceInfo> list;

    public PopupVoiceSelecter2Adapter(Context context, List<VoiceInfo> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView( int i, View view, ViewGroup viewGroup) {
        if (null == view) {
            view = LayoutInflater.from(context).inflate(R.layout.item_voiceselecter2, viewGroup, false);
        }
        CheckBox item_check_voice = (CheckBox) view.findViewById(R.id.item_check_voice);
        TextView tv_voice_name = (TextView) view.findViewById(R.id.tv_voice_name);

        tv_voice_name.setText(list.get(i).song_name);
        item_check_voice.setChecked(list.get(i).ischecked);

        return view;
    }

}
